//
//  BKMatchingProvDataSource.m
//  baokaodaxue
//
//  Created by dangyangyang on 15/5/31.
//  Copyright (c) 2015年 宏图教育. All rights reserved.
//

#import "BKMatchingProvDataSource.h"
#import <UIImageView+AFNetworking.h>

@implementation BKMatchingProvDataSource

- (id)init{

    self= [super init];
    if (self) {
        _selectedArray= [NSMutableArray array];
    }
    return self;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return    [_dataArray count];
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    BKMatchingProvTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuse];
    
    NSDictionary *dic = _dataArray[indexPath.row];
    
    if (_isComparing) {
        
        __block BOOL isSelected = NO;
        [_selectedArray enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
            if ([obj[@"cid"] isEqual:_dataArray[indexPath.row][@"cid"] ]) {
                
                isSelected = YES;
                *stop = YES;
            }
        }];
        
        if (isSelected) {
            [cell.arrowImage setImage:[UIImage imageNamed:@"selected"]];
        }else{
        
            [cell.arrowImage setImage:[UIImage imageNamed:@"unselected"]];
            
        }
        
    }else{
    
        [cell.arrowImage setImage:[UIImage imageNamed:@"arrow_black"]];
        
        
    }
    
    
    [cell.photo setImageWithURL:[NSURL URLWithString:dic[@"img"]]];

    cell.is211Label.text = [dic[@"is211"] isEqualToString:@"0"]?@"":@"211";
     cell.is985Label.text = [dic[@"is985"] isEqualToString:@"0"]?@"":@"985";
    cell.levelLabel.text = [dic[@"level"] isEqualToString:@"1"]?@"本科":@"专科";
    cell.typeLabel.text = dic[@"type"];
    cell.nameLabel.text = dic[@"name"];
    return cell;
    
}

@end
